<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style-type: none;
        }

        .box {
            width: 400px;
            height: 300px;
            border: 1px solid #ccc;
            margin: 100px auto;
            overflow: hidden;
        }

        .hd {
            height: 45px;
        }

        .hd span {
            display: inline-block;
            width: 90px;
            background-color: pink;
            line-height: 45px;
            text-align: center;
            cursor: pointer;
            color: white;
        }

        .hd span.current {
            background-color: purple;
        }

        .bd li {
            height: 255px;
            background-color: purple;
            display: none;
        }

        .bd li:nth-child(1) {
            background-color: aqua;
        }

        .bd li:nth-child(2) {
            background-color: greenyellow;
        }

        .bd li:nth-child(3) {
            background-color: orange;
        }

        .bd li.current {
            display: block;
        }
    </style>
</head>
<body>
<div class="box" id="one">
    <div class="hd">
        <span class="current">体育</span>
        <span>娱乐</span>
        <span>新闻</span>
        <span>综合</span>
    </div>
    <div class="bd">
        <ul>
            <li class="current">我是体育模块</li>
            <li>我是娱乐模块</li>
            <li>我是新闻模块</li>
            <li>我是综合模块</li>
        </ul>
    </div>
</div>


</body>
</html>
<script>


    var oBox = document.getElementById('one');
    var oLi = oBox.getElementsByTagName("li");


    var oSpan = oBox.children[0].children;  //DOM数组
    for (var i = 0; i < oSpan.length; i++) {
        //给每一个span绑定输入移入事件

        oSpan[i].index = i;
        oSpan[i].onmouseenter = test(i)


        /*
         *
         * function () {
         //1. 排他
         for (var j = 0; j < oSpan.length; j++) {
         oSpan[j].className = ""; //清空所有
         oLi[j].className="";
         }
         //2. 给当前的span加上 类名称

         this.className="current";
         oLi[this.index].className="current";


         }
         *
         *
         *
         * */
    }


    function test(index) {

        return function () {
            //我已经解决了你的下标 index

            for (var i = 0; i < oSpan.length; i++) {
                oSpan[i].className = "";

                oLi[i].className = "";
            }
//                console.log(this);
            this.className = "current";
            //给对应的 li标签添加 类样式
            oLi[index].className = "current";

        }

    }






</script>